package calao.contact;

import calao.contact.client.Group;
import calao.storage.Record;
import calao.storage.RecordBinding;

import static calao.contact.GroupDB.*;

public class GroupBinding 
extends RecordBinding<Group>
{
	
	GroupBinding()
	{
		super(Group.class);
	}

	public Group toObject(Record record)
	{
		Group info = new Group(record.get(ID));
		info.setName(record.get(NAME));
		info.setDescription(record.get(DESCRIPTION));
		return info;
	}

	public Record toRecord(Group info) 
	{
		Record rec = new Record(TABLE);
		rec.set(ID, info.getId());
		rec.set(DESCRIPTION, info.getDescription());
		rec.set(NAME, info.getName());
		return rec;
	}

}
